home *** CD-ROM | disk | FTP | other *** search
Text File | 2003-09-23 | 55.7 KB | 2,082 lines |
- function ext_XML_GET_TEXT()
- {
- return this.firstChild.nodeType != 3 ? null : this.firstChild.nodeValue;
- }
- function ext_XML_SET_TEXT(text)
- {
- this.firstChild.nodeValue = text;
- }
- function ActivityInfoItem()
- {
- }
- function ActivityInfo()
- {
- }
- function createIndexList(str, openTag, closeTag)
- {
- var len = str.length;
- var acntr = 0;
- var otag = openTag;
- var ctag = closeTag;
- var abi = [];
- var aei = [];
- while(acntr < len)
- {
- acntr = str.indexOf(otag,acntr);
- if(acntr == -1)
- {
- break;
- }
- abi.push(acntr);
- acntr += otag.length;
- }
- acntr = 0;
- while(acntr < len)
- {
- acntr = str.indexOf(ctag,acntr);
- if(acntr == -1)
- {
- break;
- }
- aei.push(acntr);
- acntr += ctag.length;
- }
- var rf = otag.length + ctag.length;
- var i = 0;
- while(i < abi.length)
- {
- if(i == 0)
- {
- aei[i] -= ctag.length - 1;
- }
- else
- {
- abi[i] -= rf * i;
- aei[i] -= rf * i + otag.length;
- }
- i++;
- }
- return {startIndex:abi,endIndex:aei,length:abi.length};
- }
- function createInstructionField(cnt, name, text)
- {
- text = simpleReplaceBlanks(text,"[:blank:]","[:/blank:]");
- var hasBold = text.indexOf("[:bold:]") != -1;
- if(cnt[name] == null)
- {
- var tmc = cnt.createEmptyMovieClip(name,1667);
- tmc.createTextField("content",1,0,0,0,0);
- }
- else
- {
- var tmc = cnt[name];
- tmc.swapDepths(1667);
- }
- tmc.isRemoveable = true;
- tmc.isRemovable = true;
- var tf = layoutInfo.instTextFormat;
- tmc.content.border = false;
- tmc.content.type = "dynamic";
- if(hasBold)
- {
- tmc.content.text = text.replace("[:bold:]","").replace("[:/bold:]","");
- }
- else
- {
- tmc.content.text = text;
- }
- tmc.content._height = 400;
- tmc.content.wordWrap = true;
- tmc.content.color = layoutInfo.instTextColor;
- tmc.content._width = 300;
- tmc.content.autoSize = true;
- tmc.content.selectable = false;
- tmc.content.setTextFormat(tf);
- tmc.content.embedFonts = true;
- if(hasBold)
- {
- var idxLists = createIndexList(text,"[:bold:]","[:/bold:]");
- var i = 0;
- while(i < idxLists.length)
- {
- tmc.content.setTextFormat(idxLists.startIndex[i],idxLists.endIndex[i],layoutInfo.instTextFormatBold);
- i++;
- }
- }
- return tmc;
- }
- function changeInstructionField(insField, newText)
- {
- createInstructionField(insField._parent,insField._name,newText);
- }
- function toggleLang()
- {
- if(PMSI.instructionLanguage == "Spanish")
- {
- PMSI.instructionLanguage = "English";
- }
- else
- {
- PMSI.instructionLanguage = "Spanish";
- }
- var instText = ai["instructions" + PMSI.instructionLanguage].text;
- if(instText != null)
- {
- var oldInstHeight = this.instructionField._height;
- changeInstructionField(this.instructionField,instText);
- var hdiff = this.instructionField._height - oldInstHeight;
- reposition(hdiff);
- }
- pencilHelper.swapLangs();
- }
- function reposition(hdiff)
- {
- var comp;
- var dupList = {};
- trace("******************************************");
- for(var mcn in this)
- {
- comp = this[mcn];
- if(comp.isMoveable && dupList[comp._name] == null)
- {
- trace("\t" + comp);
- trace("\t\t" + comp.getDepth());
- trace(hdiff);
- comp._y += hdiff;
- dupList[comp._name] = 1;
- }
- }
- trace("******************************************");
- }
- function simpleReplaceBlanks(str, stag, etag)
- {
- var cp = str.indexOf(stag);
- var ei = 0;
- while(cp != -1)
- {
- ei = str.indexOf(etag);
- str = str.substring(0,cp) + "_____" + str.substring(ei + etag.length);
- cp = str.indexOf(stag);
- }
- return str;
- }
- function loadActivity(fname)
- {
- t = getTimer();
- ai.load(fname);
- }
- function setActivityInfo(_ai)
- {
- ai = _ai;
- ai._parent = this;
- render();
- return true;
- }
- function makeForceNoWrap(line, indexArray)
- {
- var si;
- var ei;
- var i = 0;
- while(i < indexArray.length)
- {
- si = indexArray.startIndex[i];
- ei = indexArray.endIndex[i];
- var j = si + 1;
- while(j < ei)
- {
- if(line.charAt(j) == " ")
- {
- line = line.substring(0,j) + "_" + line.substring(j + 1);
- }
- j++;
- }
- i++;
- }
- return line;
- }
- function removeForceNoWrap(s)
- {
- var j = 0;
- while(j < s.length)
- {
- if(s.charAt(j) == "_")
- {
- s = s.substring(0,j) + " " + s.substring(j + 1);
- }
- j++;
- }
- return s;
- }
- function splitAtIndexes(lineLen, sline, linecount, indexArray)
- {
- if(splitAtIndexes.last_j == null || lineLen == 0)
- {
- splitAtIndexes.last_j = 0;
- }
- var arr = new Array();
- var startIndex = 0;
- var lastEndIndex = 0;
- var si;
- var ei;
- var staticChunk;
- var fillChunk;
- var j = splitAtIndexes.last_j;
- while(j < indexArray.length)
- {
- splitAtIndexes.last_j = j;
- si = indexArray.startIndex[j] - lineLen - linecount;
- ei = indexArray.endIndex[j] - lineLen - linecount;
- if(!(ei <= sline.length && si >= 0))
- {
- break;
- }
- if(si > 0 || si > lastEndIndex)
- {
- staticChunk = {text:sline.substring(lastEndIndex,si)};
- arr.push(staticChunk);
- }
- fillChunk = {text:sline.substring(si,ei),isBlank:true};
- arr.push(fillChunk);
- lastEndIndex = ei;
- j++;
- }
- if(lastEndIndex != sline.length)
- {
- staticChunk = {text:sline.substring(lastEndIndex)};
- arr.push(staticChunk);
- }
- return arr;
- }
- function createFillBox(s, px, py, w, id)
- {
- var ilist = createIndexList(s);
- var tempstr = s.multiSplit(TAGS.BLANK_OPEN,TAGS.BLANK_CLOSE);
- var testStr = tempstr.join("");
- var ts;
- var te;
- this.createTextField("__fio__",613147,0,0,w,0);
- __fio__.wordWrap = true;
- __fio__.multiline = true;
- __fio__.border = true;
- __fio__.autoSize = true;
- __fio__.embedFonts = true;
- __fio__.text = makeForceNoWrap(testStr,ilist);
- __fio__.setTextFormat(layoutInfo.qStaticText);
- var lines = __fio__.getLines();
- __fio__.removeTextField();
- var tb_pos = {x:px,y:py};
- var last_j = 0;
- var track_j = 0;
- var last_x = 0;
- var lastIndex = 0;
- var totalLineLen = 0;
- var atxt = [];
- var fullTextLine = "";
- var lastTFClip = null;
- var tabCounter = 100;
- var line;
- var txt;
- var chunk;
- var lineChunks;
- var oldtxt;
- var tqm;
- var tq;
- var tam;
- var tm;
- var chunkText;
- s;
- var fibHolderRef = this.createEmptyMovieClip("fibHolder" + id,depth++);
- fibHolderRef._x = tb_pos.x;
- fibHolderRef._y = tb_pos.y;
- fibHolderRef.gAnswerBoxes = [];
- fibHolderRef.isRemoveable = true;
- var i = 0;
- while(i < lines.length)
- {
- line = lines[i];
- fullTextLine += line + " ";
- s;
- s;
- fibHolderRef.createTextField("tx" + i,1 + i,0,0,w,0);
- txt = fibHolderRef["tx" + i];
- atxt.push(txt);
- txt.border = false;
- txt.autoSize = true;
- txt.embedFonts = true;
- txt.text = lines[i];
- txt.setTextFormat(layoutInfo.qStaticText);
- if(i > 0)
- {
- oldtxt = fibHolderRef["tx" + (i - 1)];
- txt._y = oldtxt._y + oldtxt._height + 2;
- }
- lineChunks = new Array();
- startIndex = 0;
- lineChunks = splitAtIndexes(totalLineLen,line,0,ilist);
- var j = 0;
- while(j < lineChunks.length)
- {
- chunk = lineChunks[j];
- chunkText = chunk.text;
- if(chunk.isBlank == undefined)
- {
- te = layoutInfo.qStaticText.cGetTextExtent(chunkText);
- tqm = fibHolderRef.createEmptyMovieClip("tqm" + i + "_" + i,depth++);
- tqm.isRemoveable = true;
- tqm._x = txt._x + last_x;
- tqm._y = txt._y;
- tqm.createTextField("txt",1,0,0,te.width,te.height);
- tq = tqm.txt;
- tq.type = "dynamic";
- tq.selectable = false;
- tq.embedFonts = true;
- tq.text = chunkText;
- tq.setTextFormat(layoutInfo.qStaticText);
- tq.setNewTextFormat(layoutInfo.qStaticText);
- s;
- lastTFClip = tqm;
- }
- else
- {
- te2 = layoutInfo.qStaticText.cGetTextExtent(chunkText);
- tam = fibHolderRef.createEmptyMovieClip("tam" + i + "_" + j,depth++);
- tam.isRemoveable = true;
- tam._x = lastTFClip != null ? last_x : txt._x;
- tam._y = txt._y;
- tam.createTextField("txt",1,0,0,te2.width + 4,te2.height);
- ta = tam.txt;
- fibHolderRef.gAnswerBoxes.push(ta);
- gAnswerBoxes.push(ta);
- ta.type = "input";
- ta.selectable = true;
- ta.border = true;
- ta.borderColor = 13421772;
- ta.embedFonts = true;
- ta.tabIndex = tabCounter++;
- ta.correctAnswer = removeForceNoWrap(chunkText);
- ta.setNewTextFormat(layoutInfo.qFillText);
- s;
- lastTFClip = tam;
- }
- last_x = lastTFClip._x + lastTFClip._width;
- j++;
- }
- lastTFClip = null;
- lastIndex = 0;
- last_x = 0;
- totalLineLen = fullTextLine.length;
- i++;
- }
- var i = 0;
- while(i < atxt.length)
- {
- atxt[i].removeTextField();
- i++;
- }
- return fibHolderRef;
- }
- function render()
- {
- depth = 1000;
- tabOrder = 4000;
- _global.gAnswerBoxes = new Array();
- clearClip();
- tableY = layoutInfo.box.y;
- rightSideBuffer = layoutInfo.rightSideBuffer;
- topBuffer = 0;
- if(master.hasVideoPlayer)
- {
- tableY = layoutInfo.temp4InstY;
- topBuffer = master.videoPlayer._height;
- rightSideBuffer = 250;
- }
- if(master.hasMediaFrame)
- {
- rightSideBuffer = 250;
- }
- var title_mc;
- var inst_mc;
- if(ai.titleSpanish)
- {
- title_mc = createTitleField(ai.titleSpanish);
- title_mc.isRemoveable = true;
- title_mc._x = layoutInfo.box.x;
- title_mc._y = layoutInfo.box.y + topBuffer;
- tableY = title_mc._y + title_mc._height;
- }
- if(ai.instructionsEnglish || ai.instructionsSpanish)
- {
- if(ai.instructionsEnglish != null)
- {
- var instText = ai.instructionsEnglish.text;
- }
- else
- {
- var instText = ai.instructionsSpanish.text;
- }
- pinstText = ai["instructions" + PMSI.instructionLanguage].text;
- instText = pinstText != null ? pinstText : instText;
- inst_mc = this.createInstructionField(this,"inst",instText);
- inst_mc.isRemoveable = true;
- inst_mc._x = layoutInfo.box.x;
- inst_mc._y = title_mc == null ? tableY : title_mc._y + title_mc._height;
- inst_mc._height;
- tableY = inst_mc._y + inst_mc._height + 10;
- this.instructionField = inst_mc;
- trace("tableY: " + tableY);
- trace("inst_mc._y + inst_mc._height + 10; " + (inst_mc._y + inst_mc._height + 10));
- }
- if(ai.model)
- {
- this.attachMovie("modeloButton","modelBtn",10);
- modelBtn._x = layoutInfo.box.x;
- modelBtn._y = tableY - 10;
- trace("modelBtn._y" + modelBtn._y);
- modelBtn.isMoveable = true;
- this.attachMovie("modeloBox","modeloBox",100000);
- modeloBox.isRemoveable = true;
- modeloBox._visible = false;
- modelBtn.onRelease = function()
- {
- if(!this._parent.modeloBox.isBoxDrawn)
- {
- this._parent.modeloBox.drawPopUp(ai.model.text);
- this._parent.modeloBox.isBoxDrawn = true;
- }
- this._parent.modeloBox._visible = !this._parent.modeloBox._visible;
- this._parent.modeloBox._x = this._x + this._width + 24;
- this._parent.modeloBox._y = this._y + this._height / 2 - 8;
- };
- }
- else
- {
- modelBtn._visible = false;
- }
- if(_parent.actNumber_mc._height > inst_mc._height + title_mc._height)
- {
- tableY = _parent.actNumber_mc._y + _parent.actNumber_mc._height + 10;
- }
- var gtt = getTimer();
- var tfMaxWidth = layoutinfo.MAX_WIDTH;
- var qlist = ai.questions.question;
- var dx = layoutInfo.box.x;
- var dy = tableY + 10;
- var lastClip;
- var fcfb;
- var qstr;
- var qnum;
- var wid;
- var qst;
- var qtb;
- if(qlist.length > 1)
- {
- var i = 0;
- while(i < qlist.length)
- {
- qst = qlist[i];
- qnum = createNumberField("qnum" + i,i + 1 + ".",i);
- qnum.isRemoveable = true;
- qnum.isMoveable = true;
- qstr = qlist[i].questionText.text;
- dy = i != 0 ? lastClip._y + lastClip._height + 10 : dy;
- qnum._y = dy;
- qnum._x = dx;
- wid = tfMaxWidth - rightSideBuffer - qnum._width - 10;
- if(qst.questionText)
- {
- qtb = createQuestionField("gtb" + i,qst.questionText.text,wid,i);
- qtb._x = dx + qnum._width + 10;
- qtb._y = dy;
- qtb.isRemoveable = true;
- qtb.isMoveable = true;
- }
- if(ai.isScoreable.text == "y")
- {
- feedbackCheck = this.attachMovie("check","chk" + depth++,depth);
- feedbackCheck.isRemoveable = true;
- feedbackCheck.isMoveable = true;
- }
- fcfb = createShortAnswerField("sab_box" + i,wid - feedBackCheck._width,i);
- fcfb.content.feedBackCheck = feedbackCheck;
- fcfb.content.tabIndex = tabOrder++;
- fcfb.content.correctAnswer = qst.correctAnswer.text;
- fcfb._x = qtb != null ? qtb._x : dx + qnum._width + 10;
- fcfb._y = qtb != null ? qtb._y + qtb._height + 2 : dy;
- feedbackCheck._x = fcfb._x + fcfb._width;
- feedbackCheck._y = fcfb._y;
- fcfb.isRemoveable = true;
- fcfb.isMoveable = true;
- lastClip = fcfb;
- gAnswerBoxes[i] = fcfb.content;
- i++;
- }
- }
- else
- {
- var mc = this.createEmptyMovieClip("bigField",6220);
- mc.isRemoveable = true;
- mc.isMoveable = true;
- mc.createTextField("content",1,0,0,0,0);
- var tf = layoutInfo.qFillText;
- var te = tf.cGetTextExtent("_");
- tf.align = "left";
- mc.content.embedFonts = true;
- mc.content.tabIndex = tabOrder++;
- mc.content.border = true;
- mc.content.borderColor = layoutInfo.qFillText.color;
- mc.content.type = "input";
- mc.content.setTextFormat(tf);
- mc.content._height = te.height * 6;
- mc.content.wordWrap = true;
- mc.content.multiline = true;
- mc.content._width = tfMaxWidth - rightSideBuffer;
- mc.content.autoSize = false;
- mc.content.selectable = true;
- mc.content.setNewTextFormat(tf);
- mc._x = dx;
- mc._y = dy;
- Selection.setFocus(mc.content);
- gAnswerBoxes[0] = mc.content;
- }
- _global.defaultBox = gAnswerBoxes[0];
- initDiacriticalHandlers();
- s;
- if(ai.audioFile)
- {
- this.gotoAndStop("higher");
- }
- else if(ai.artFile)
- {
- this.gotoAndStop("high");
- }
- else
- {
- this.gotoAndStop("default");
- }
- }
- function drawDottedLine(x, y, w)
- {
- var mcdl = this.createEmptyMovieClip("dotline",depth++);
- mcdl._x = x;
- mcdl._y = y;
- mcdl.lineStyle(2,13421772,50);
- var d = 0;
- while(d < w)
- {
- if(d % 8 == 0)
- {
- mcdl.moveTo(d + 8,0);
- mcdl.lineTo(d + 4,0);
- }
- d++;
- }
- }
- function checkAnswers()
- {
- var counter = 0;
- var i = 0;
- while(i < gAnswerBoxes.length)
- {
- if(gAnswerBoxes[i].correctAnswer.trim() == gAnswerBoxes[i].text.trim())
- {
- counter++;
- gAnswerBoxes[i].feedbackCheck.gotoAndStop("correct");
- }
- else
- {
- gAnswerBoxes[i].feedbackCheck.gotoAndStop("incorrect");
- }
- i++;
- }
- master.setFeedback(counter,gAnswerBoxes.length);
- }
- function toggleBox()
- {
- __fio__._visible = !__fio__._visible;
- }
- function clearClip()
- {
- delete _global.gAnswerBoxes;
- _global.gAnswerBoxes = [];
- layoutInfo.qMaxWidthPos = 0;
- layoutInfo.qMaxWidth = 0;
- layoutInfo.a1MaxWidth = 0;
- layoutInfo.a2MaxWidth = 0;
- for(var mcn in this)
- {
- if(this[mcn].isRemoveable)
- {
- this[mcn].clear();
- this[mcn].removeMovieClip();
- }
- }
- }
- function createTitleField(txt)
- {
- var mc = this.createEmptyMovieClip("title",4900);
- mc.createTextField("content",1,0,0,0,0);
- var tf = layoutInfo.titleTextFormat;
- mc.content.embedFonts = true;
- mc.content.border = false;
- mc.content.type = "dynamic";
- mc.content.text = txt;
- mc.content.setTextFormat(tf);
- mc.content.wordWrap = true;
- mc.content.color = layoutInfo.instTextColor;
- mc.content._width = 300;
- mc.content.autoSize = true;
- mc.content.selectable = false;
- return mc;
- }
- function createQuestionField(name, text, width, id)
- {
- var mc = this.createEmptyMovieClip(name,4120 + id);
- mc.createTextField("content",1,0,0,0,0);
- var tf = layoutInfo.qTextFormatSA;
- mc.content.embedFonts = true;
- mc.content.border = false;
- mc.content.type = "dynamic";
- mc.content.text = text;
- mc.content.setTextFormat(tf);
- mc.content._height = 400;
- mc.content.wordWrap = true;
- mc.content.color = layoutInfo.instTextColor;
- mc.content._width = width;
- mc.content.autoSize = true;
- mc.content.selectable = false;
- return mc;
- }
- function createShortAnswerField(name, width, id)
- {
- var mc = this.createEmptyMovieClip(name,6120 + id);
- mc.createTextField("content",1,0,0,0,0);
- var tf = layoutInfo.qFillText;
- tf.align = "left";
- var te = tf.cGetTextExtent("_");
- mc.content.embedFonts = true;
- mc.content.borderColor = 13421772;
- mc.content.type = "input";
- mc.content.text = text;
- mc.content.setNewTextFormat(tf);
- mc.content._height = te.height;
- mc.content.wordWrap = false;
- mc.content._width = width;
- mc.content.autoSize = false;
- mc.content.selectable = true;
- mc.lineStyle(1,layoutInfo.qFillText.color,100);
- mc.drawUnderline();
- return mc;
- }
- function createNumberField(name, text, dep)
- {
- var mc = this.createEmptyMovieClip(name,8101 + dep);
- mc.createTextField("content",1,0,0,40,0);
- var tf = layoutInfo.qNumberText;
- mc.content.embedFonts = true;
- mc.content.border = false;
- mc.content.type = "dynamic";
- mc.content.autoSize = true;
- mc.content.text = text;
- mc.content.setTextFormat(tf);
- mc.content.selectable = false;
- return mc;
- }
- if(_global.PMSI == null)
- {
- _global.PMSI = {};
- PMSI.VENDOR_NAME = "Purple Monkey Studios, Inc.";
- PMSI.DefList = {};
- }
- String.prototype.trim = function()
- {
- return this.rtrim().ltrim();
- };
- String.prototype.rtrim = function()
- {
- var i = this.length - 1;
- while(i >= 0 && this.charCodeAt(i) <= 32)
- {
- i--;
- }
- return this.substring(0,i + 1);
- };
- String.prototype.ltrim = function()
- {
- var i = 0;
- while(i < this.length && this.charCodeAt(i) <= 32)
- {
- i++;
- }
- return this.substring(i);
- };
- String.prototype.isWhiteSpace = function()
- {
- var i = 0;
- while(i < this.length)
- {
- if(this.charCodeAt(i) > 32)
- {
- return false;
- }
- i++;
- }
- return true;
- };
- String.prototype.toCharArray = function()
- {
- return this.split("");
- };
- Array.prototype.charArrayToString = function()
- {
- return this.join("");
- };
- String.prototype.reverse = function()
- {
- return this.split("").reverse().join("");
- };
- String.prototype.multiSplit = function()
- {
- var master;
- var dummy;
- var args;
- master = this.split(arguments[0]);
- var i = 1;
- while(i < arguments.length)
- {
- var j = 0;
- while(j < master.length)
- {
- dummy = master[j].split(arguments[i]);
- if(dummy.length > 1)
- {
- args = [j,1];
- args = args.concat(dummy);
- master.splice.apply(master,args);
- }
- j++;
- }
- i++;
- }
- return master;
- };
- String.prototype.replace = function(srch, repl)
- {
- return this.split(srch).join(repl);
- };
- XML.prototype.ELEMENT_NODE = 1;
- XML.prototype.TEXT_NODE = 3;
- XML.prototype._inorderItr = function(node, fnPtr)
- {
- var stack = new Array();
- var node = node;
- while(true)
- {
- if(node)
- {
- stack.push(node);
- node = node.firstChild;
- }
- else
- {
- node = stack.pop();
- if(!node)
- {
- break;
- }
- fnPtr(node);
- node = node.nextSibling;
- }
- }
- delete stack;
- };
- XMLNode.prototype._inorderItr = XML.prototype._inorderItr;
- XML.prototype._inorderRec = function(node, fnPtr)
- {
- function helperR(node_xml)
- {
- if(node_xml == null)
- {
- return undefined;
- }
- this.fnPtr(node_xml);
- helperR(node_xml.firstChild);
- helperR(node_xml.nextSibling);
- }
- var outer = this;
- helperR(node);
- };
- XMLNode.prototype._inorderRec = XML.prototype._inorderRec;
- XMLNode.prototype.addProperty("text",this.ext_XML_GET_TEXT,this.ext_XML_SET_TEXT);
- XML.prototype.addProperty("text",this.ext_XML_GET_TEXT,this.ext_XML_SET_TEXT);
- XML.prototype.getElementsByTagName = function(tagName)
- {
- function processNode(node)
- {
- if(node.nodeName != null && node.nodeName == tagName)
- {
- nodelist.push(node);
- }
- }
- var nodelist = new Array();
- this._inorderItr(this,processNode);
- return nodelist;
- };
- XMLNode.prototype.getElementsByTagName = XML.prototype.getElementsByTagName;
- XML.prototype.getElementsByTagNames = function()
- {
- function processNode(node)
- {
- var i = 0;
- while(i < args.length)
- {
- if(node.nodeName != null && node.nodeName == args[i])
- {
- trace("Found: " + args[i]);
- if(nodelists[i] == undefined)
- {
- nodelists[i] = new Array();
- }
- nodelists[i].push(node);
- break;
- }
- i++;
- }
- }
- var args = arguments;
- var nodelists = new Array(arguments.length);
- this._inorderItr(this,processNode);
- return nodelists;
- };
- XMLNode.prototype.getElementsByTagNames = XML.prototype.getElementsByTagNames;
- XML.prototype.getValueAtTagName = function(tagName)
- {
- function processNode(node)
- {
- if(node.nodeName != null && node.nodeName == tagName)
- {
- nodelist.push(node);
- }
- }
- var nodelist = new Array();
- var textValue = null;
- this._inorderItr(this,processNode);
- if(nodeList.length >= 1)
- {
- textValue = nodeList[0].text;
- }
- return textValue;
- };
- XMLNode.prototype.getValueAtTagName = XML.prototype.getValueAtTagName;
- XML.prototype.getAttribute = function(name)
- {
- return this.attributes[name];
- };
- XMLNode.prototype.getAttribute = XML.prototype.getAttribute;
- XML.prototype.setAttribute = function(name, value)
- {
- this.attributes[name] = value;
- };
- XMLNode.prototype.setAttribute = XML.prototype.setAttribute;
- XML.prototype.hasAttribute = function(name)
- {
- var attrs = this.attributes;
- for(var mc in attrs)
- {
- if(name == mc)
- {
- return true;
- }
- }
- return false;
- };
- XMLNode.prototype.hasAttribute = XML.prototype.hasAttribute;
- XML.prototype.removeAttribute = function(name)
- {
- var attr = this.attributes[name];
- delete this.attributes[name];
- return attr;
- };
- XMLNode.prototype.setAttribute = XML.prototype.setAttribute;
- XMLNode.prototype.getOwnerDocument = function()
- {
- var odc = this;
- var lastNode = this;
- while(odc)
- {
- lastNode = odc;
- odc = odc.parentNode;
- }
- return !(lastNode instanceof XML) ? null : lastNode;
- };
- XML.prototype.normalize = function()
- {
- function process(node)
- {
- nodeList.push(node);
- }
- var outer = this;
- var nodeList = new Array();
- this._inorderItr(this,process);
- var i = 0;
- while(i < nodeList.length)
- {
- var node = nodeList[i];
- if(node.nodeType == XML.prototype.TEXT_NODE && node.nodeValue.isWhiteSpace())
- {
- trace("removing node");
- node.removeNode();
- }
- else if(node.nodeType == XML.prototype.TEXT_NODE)
- {
- node.nodeValue = node.nodeValue.trim();
- }
- i++;
- }
- delete nodeList;
- };
- XMLNode.prototype.normalize = XML.prototype.normalize;
- XMLNode.prototype.getDepth = function()
- {
- var i = 0;
- var node = this;
- while(node)
- {
- node = node.parentNode;
- i++;
- }
- return i;
- };
- XML.prototype.getElementsWithAttribute = function(name, value)
- {
- function processNode(node)
- {
- if(value == null)
- {
- for(var mcz in node.attributes)
- {
- if(mcz == name)
- {
- nodeList.push(node);
- break;
- }
- }
- }
- else if(node.attributes[name] == value)
- {
- nodeList.push(node);
- }
- }
- if(name == null)
- {
- return undefined;
- }
- var nodeList = new Array();
- this._inorderItr(this,processNode);
- return nodeList;
- };
- XMLNode.prototype.getElementsWithAttribute = XML.prototype.getElementsWithAttribute;
- XMLNode.prototype.getPath = function(path)
- {
- function process(node)
- {
- trace(node.nodeName);
- if(node.nodeName != null && node.nodeName == currentPart && i < pathParts.length)
- {
- trace("Found: " + currentPart);
- partTable[i] = node.parentNode.getElementsByTagName(currentPart);
- currentPart = pathParts[++i];
- }
- }
- var i = 0;
- var pathParts = path.split("/");
- var currentPart = pathParts[i];
- var partTable = new Array();
- this._inorderItr(this,process);
- return partTable[partTable.length - 1];
- };
- XML.prototype.getPath = XMLNode.prototype.getPath;
- MovieClip.prototype.isLoading = function()
- {
- return this.getBytesLoaded() > 4 && this.getBytesTotal() > this.getBytesLoaded();
- };
- MovieClip.prototype.getPercentLoaded = function()
- {
- return Math.round(this.getBytesLoaded() / this.getBytesTotal() * 100);
- };
- MovieClip.prototype.isLoaded = function()
- {
- return !this.isLoading();
- };
- MovieClip.prototype._sol = function(f)
- {
- if(MovieClip.prototype.__onLoadHandler__ == undefined)
- {
- MovieClip.prototype.__onLoadHandler__ = {};
- }
- MovieClip.prototype.__onLoadHandler__[this] = f;
- };
- MovieClip.prototype._gol = function()
- {
- return MovieClip.prototype.__onLoadHandler__[this];
- };
- MovieClip.prototype.addProperty("onLoad",MovieClip.prototype._gol,MovieClip.prototype._sol);
- MovieClip.prototype._sod = function(f)
- {
- if(MovieClip.prototype.__onDataHandler__ == undefined)
- {
- MovieClip.prototype.__onDataHandler__ = {};
- }
- MovieClip.prototype.__onDataHandler__[this] = f;
- };
- MovieClip.prototype._god = function()
- {
- return MovieClip.prototype.__onDataHandler__[this];
- };
- MovieClip.prototype.addProperty("onData",MovieClip.prototype._god,MovieClip.prototype._sod);
- MovieClip.prototype.load = MovieClip.prototype.loadMovie;
- MovieClip.prototype.drawOval = function(x, y, radius, yRadius)
- {
- if(arguments.length < 3)
- {
- return undefined;
- }
- var theta;
- var xrCtrl;
- var yrCtrl;
- var angle;
- var angleMid;
- var px;
- var py;
- var cx;
- var cy;
- if(yRadius == undefined)
- {
- yRadius = radius;
- }
- theta = 0.7853981633974483;
- xrCtrl = radius / Math.cos(theta / 2);
- yrCtrl = yRadius / Math.cos(theta / 2);
- angle = 0;
- this.moveTo(x + radius,y);
- var i = 0;
- while(i < 8)
- {
- angle += theta;
- angleMid = angle - theta / 2;
- cx = x + Math.cos(angleMid) * xrCtrl;
- cy = y + Math.sin(angleMid) * yrCtrl;
- px = x + Math.cos(angle) * radius;
- py = y + Math.sin(angle) * yRadius;
- this.curveTo(cx,cy,px,py);
- i++;
- }
- };
- MovieClip.prototype.drawCircle = function(x, y, r)
- {
- this.drawOval(x,y,r);
- };
- MovieClip.prototype.drawSquare = function(x, y, w)
- {
- this.drawRect(x,y,w,w);
- };
- MovieClip.prototype.drawEgg = function(x, y, r)
- {
- var rx = r / 1.618;
- var ry = r;
- var ry1 = 2 * ry * 0.618;
- var ry2 = 2 * ry * 0.382;
- this.moveTo(x + rx,y);
- this.curveTo(rx + x,-0.4142 * ry1 + y,0.7071 * rx + x,-0.7071 * ry1 + y);
- this.curveTo(0.4142 * rx + x,- ry1 + y,x,- ry1 + y);
- this.curveTo(-0.4142 * rx + x,- ry1 + y,-0.7071 * rx + x,-0.7071 * ry1 + y);
- this.curveTo(- rx + x,-0.4142 * ry1 + y,- rx + x,y);
- this.curveTo(- rx + x,0.4142 * ry2 + y,-0.7071 * rx + x,0.7071 * ry2 + y);
- this.curveTo(-0.4142 * rx + x,ry2 + y,x,ry2 + y);
- this.curveTo(0.4142 * rx + x,ry2 + y,0.7071 * rx + x,0.7071 * ry2 + y);
- this.curveTo(rx + x,0.4142 * ry2 + y,rx + x,y);
- };
- MovieClip.prototype.drawRect = function(x, y, w, h, cornerRadius)
- {
- if(arguments.length < 4)
- {
- return undefined;
- }
- if(cornerRadius > 0)
- {
- var theta;
- var angle;
- var cx;
- var cy;
- var px;
- var py;
- if(cornerRadius > Math.min(w,h) / 2)
- {
- cornerRadius = Math.min(w,h) / 2;
- }
- theta = 0.7853981633974483;
- this.moveTo(x + cornerRadius,y);
- this.lineTo(x + w - cornerRadius,y);
- angle = -1.5707963267948966;
- cx = x + w - cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- cy = y + cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- px = x + w - cornerRadius + Math.cos(angle + theta) * cornerRadius;
- py = y + cornerRadius + Math.sin(angle + theta) * cornerRadius;
- this.curveTo(cx,cy,px,py);
- angle += theta;
- cx = x + w - cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- cy = y + cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- px = x + w - cornerRadius + Math.cos(angle + theta) * cornerRadius;
- py = y + cornerRadius + Math.sin(angle + theta) * cornerRadius;
- this.curveTo(cx,cy,px,py);
- this.lineTo(x + w,y + h - cornerRadius);
- angle += theta;
- cx = x + w - cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- cy = y + h - cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- px = x + w - cornerRadius + Math.cos(angle + theta) * cornerRadius;
- py = y + h - cornerRadius + Math.sin(angle + theta) * cornerRadius;
- this.curveTo(cx,cy,px,py);
- angle += theta;
- cx = x + w - cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- cy = y + h - cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- px = x + w - cornerRadius + Math.cos(angle + theta) * cornerRadius;
- py = y + h - cornerRadius + Math.sin(angle + theta) * cornerRadius;
- this.curveTo(cx,cy,px,py);
- this.lineTo(x + cornerRadius,y + h);
- angle += theta;
- cx = x + cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- cy = y + h - cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- px = x + cornerRadius + Math.cos(angle + theta) * cornerRadius;
- py = y + h - cornerRadius + Math.sin(angle + theta) * cornerRadius;
- this.curveTo(cx,cy,px,py);
- angle += theta;
- cx = x + cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- cy = y + h - cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- px = x + cornerRadius + Math.cos(angle + theta) * cornerRadius;
- py = y + h - cornerRadius + Math.sin(angle + theta) * cornerRadius;
- this.curveTo(cx,cy,px,py);
- this.lineTo(x,y + cornerRadius);
- angle += theta;
- cx = x + cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- cy = y + cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- px = x + cornerRadius + Math.cos(angle + theta) * cornerRadius;
- py = y + cornerRadius + Math.sin(angle + theta) * cornerRadius;
- this.curveTo(cx,cy,px,py);
- angle += theta;
- cx = x + cornerRadius + Math.cos(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- cy = y + cornerRadius + Math.sin(angle + theta / 2) * cornerRadius / Math.cos(theta / 2);
- px = x + cornerRadius + Math.cos(angle + theta) * cornerRadius;
- py = y + cornerRadius + Math.sin(angle + theta) * cornerRadius;
- this.curveTo(cx,cy,px,py);
- }
- else
- {
- this.moveTo(x,y);
- this.lineTo(x + w,y);
- this.lineTo(x + w,y + h);
- this.lineTo(x,y + h);
- this.lineTo(x,y);
- }
- };
- MovieClip.prototype.getCenterPoint = function()
- {
- return {x:this._width / 2,y:this._height / 2};
- };
- MovieClip.prototype.drawDebugBorderD = function()
- {
- this.lineStyle(1,0,25);
- var x;
- var y = 0;
- var w = this._width;
- var h = this._height;
- this.moveTo(x,y);
- this.lineTo(x + w,y);
- this.lineTo(x + w,y + h);
- this.lineTo(x,y + h);
- this.lineTo(x,y);
- };
- MovieClip.prototype.drawUnderline = function(len)
- {
- len = len != null ? len : this._width;
- this.moveTo(0,this._height);
- this.lineTo(len,this._height);
- };
- if(PMSI.DepthManager == undefined)
- {
- PMSI.DepthManager = {};
- PMSI.DepthManager._$depth = 0;
- PMSI.DepthManager.getNextDepth = function()
- {
- var next_depth = ++this._$depth;
- while(this._$depthsClaimed["dc" + next_depth])
- {
- next_depth = ++this._$depth;
- }
- return next_depth;
- };
- PMSI.DepthManager.reserveDepth = function(d)
- {
- if(this._$depthsClaimed == null)
- {
- this._$depthsClaimed = {};
- }
- if(d == null)
- {
- var d = ++this._$depth;
- }
- while(this._$depthsClaimed["dc" + d])
- {
- d++;
- }
- this._$depthsClaimed["dc" + d] = d;
- return d;
- };
- }
- ActivityInfoItem.prototype.toString = function()
- {
- return this.text;
- };
- ActivityInfo.prototype.getIdString = function(separator)
- {
- var sep = separator != null ? separator : ".";
- var idStr = "C" + this.activity.course + sep;
- idStr += "U" + this.activity.unit + sep;
- idStr += "S" + this.activity.section + sep;
- idStr += this.activity.topic + sep;
- if(this.activity.topicSet)
- {
- idStr += this.activity.topicSet + sep;
- }
- idStr += this.activity.difficultyLevel + this.activity.number.text;
- return idStr;
- };
- ActivityInfo.prototype.getId = ActivityInfo.prototype.getIdString;
- ActivityInfo.prototype.getType = function()
- {
- return this.activity.type;
- };
- ActivityInfo.prototype.hasAudio = function()
- {
- return this.activity.audioFile == null ? false : true;
- };
- ActivityInfo.prototype.hasVideo = function()
- {
- return this.activity.videoFile == null ? false : true;
- };
- ActivityInfo.prototype.hasPicture = function()
- {
- return this.activity.artFile == null ? false : true;
- };
- ActivityInfo.prototype.setResolve = function()
- {
- this.__resolve = ActivityInfo.prototype._myResolve;
- };
- ActivityInfo.prototype._myResolve = function(name)
- {
- return this.activity[name];
- };
- ActivityInfo.prototype.getBytesLoaded = function()
- {
- return this.xmlSource.getBytesLoaded();
- };
- ActivityInfo.prototype.getBytesTotal = function()
- {
- return this.xmlSource.getBytesTotal();
- };
- ActivityInfo.prototype.load = function(url)
- {
- this._reset();
- this.xmlSource = new XML();
- var x = this.xmlSource;
- x.parent = this;
- x.ignoreWhite = true;
- x.createAttributeArray = function(attrs)
- {
- };
- x.onLoad = function(success)
- {
- function helperR(node_xml, obj)
- {
- if(node_xml == null)
- {
- return undefined;
- }
- var nName = node_xml.nodeName;
- if(nName == "number")
- {
- nName = "activityNumber";
- }
- if(nName != null && obj[nName] == null)
- {
- var newObj = new ActivityInfoItem();
- newObj.text = node_xml.text.trim();
- if(node_xml.attributes)
- {
- trace("creating new attributes array");
- newObj.attributes = {};
- for(var oname in node_xml.attributes)
- {
- newObj.attributes[oname] = node_xml.attributes[oname];
- }
- }
- obj[nName] = newObj;
- }
- else if(!(obj[nName] instanceof Array) && obj[nName] != null)
- {
- var temp = obj[nName];
- obj[nName] = [];
- obj[nName].push(temp);
- }
- var childObject = obj[nName];
- if(childObject instanceof Array)
- {
- var newObj = new ActivityInfoItem();
- newObj.text = node_xml.text.trim();
- if(node_xml.attributes)
- {
- trace("creating new attributes array");
- newObj.attributes = {};
- for(var oname in node_xml.attributes)
- {
- newObj.attributes[oname] = node_xml.attributes[oname];
- }
- }
- childObject = newObj;
- obj[nName].push(childObject);
- }
- helperR(node_xml.firstChild,childObject);
- helperR(node_xml.nextSibling,obj);
- }
- if(success)
- {
- helperR(this.firstChild,this.parent);
- this.parent.setResolve();
- }
- this.parent.onLoad(success);
- };
- x.load(url);
- };
- ActivityInfo.prototype._reset = function()
- {
- delete this.xmlSource;
- delete this.__resolve;
- delete this.activity;
- };
- TableClass = function(parent)
- {
- this.parent = parent;
- this.reduceTextFields = true;
- this.rows = [];
- this.maxCellDims = {width:0,height:0};
- this.cellPadding = 4;
- this.cellSpacing = 4;
- this.colWidthMaxs = [];
- this.colPercentTable = [];
- this.borderSize = 1;
- this.width = 0;
- this.height = 0;
- this.oldWidth = this.width;
- this.oldHeight = this.oldHeight;
- this.originalWidth = 0;
- this.x = 0;
- this.y = 0;
- this.alteredColumns = {};
- var dep = PMSI.DepthManager.getNextDepth();
- this.borderClip = parent.createEmptyMovieClip("TableClassBorder" + dep,dep);
- };
- TableClass.prototype.setPosition = function(position)
- {
- this.x = position.x;
- this.y = position.y;
- };
- TableClass.prototype.getPosition = function()
- {
- return {x:this.x,y:this.y};
- };
- TableClass.prototype.setBorder = function(bsize)
- {
- this.borderSize = bsize;
- };
- TableClass.prototype.addRow = function(newRow)
- {
- this.rows.push(newRow);
- var cells = newRow.cells;
- var cellCount = cells.length;
- var cwms = this.colWidthMaxs;
- var cw = null;
- var newWidth = 0;
- var con = null;
- var c = 0;
- while(c < cellCount)
- {
- con = cells[c].getContent();
- cw = con == null ? cells[c].width : con._width;
- if(cwms[c] == null)
- {
- cwms[c] = cw;
- }
- else
- {
- cwms[c] = cw <= cwms[c] ? cwms[c] : cw;
- }
- newWidth += cwms[c];
- c++;
- }
- this.originalWidth = newWidth;
- this.width = newWidth;
- trace("NEW WIDTH: " + this.width);
- };
- TableClass.prototype.addRowSpacer = function(height, width, numCols)
- {
- if(numCols == null && this.rows.length == 0)
- {
- return undefined;
- }
- numCols = this.rows[0].cells.length;
- var spacerRow = new TableRow();
- var spacerCell = null;
- var i = 0;
- while(i < numCols)
- {
- spacerCell = new TableCell();
- spacerCell.height = height;
- spacerCell.width = width;
- spacerRow.addCell(spacerCell);
- i++;
- }
- this.addRow(spacerRow);
- };
- TableClass.prototype.setCellPadding = function(cellPadding)
- {
- this.cellPadding = cellPadding;
- this.redraw();
- };
- TableClass.prototype.setCellSpacing = function(cellSpacing)
- {
- this.cellSpacing = cellSpacing;
- this.redraw();
- };
- TableClass.prototype.setWidth = function(width)
- {
- this.oldWidth = this.width;
- this.width = width;
- this._recalcDimensions(width);
- this.redraw();
- this.redraw();
- };
- TableClass.prototype.setHeight = function(height)
- {
- this.oldHeight = this.height;
- this.height = height;
- this.redraw();
- };
- TableClass.prototype.redraw = function()
- {
- this.borderClip.clear();
- var rows = this.rows;
- var rc = rows.length;
- var tmdims = this.maxCellDims;
- var x;
- var y;
- var r;
- var cc;
- var con;
- var cols;
- var rmdims;
- var cell;
- var cmax;
- var offset;
- var voffset;
- var cwid;
- var wprec;
- var newwid;
- var lastColMax = null;
- var cpad = this.cellPadding;
- var cspace = this.cellSpacing;
- var r = 0;
- while(r < rc)
- {
- cols = rows[r].cells;
- cc = cols.length;
- rmdims = rows[r - 1].maxCellDims;
- if(r == 0)
- {
- y = this.y;
- }
- else
- {
- y += rmdims.height + this.cellSpacing;
- }
- var c = 0;
- while(c < cc)
- {
- cell = cols[c];
- con = cell.getContent();
- cwid = this.colWidthMaxs[c];
- this._resizeTextfield(con,cwid);
- if(cell.halign == "right")
- {
- offset = cwid - con._width;
- }
- else if(cell.halign == "center")
- {
- offset = (cwid - con._width) / 2;
- }
- else
- {
- offset = 0;
- }
- if(cell.valign == "bottom")
- {
- voffset = rows[r].maxCellDims.height - con._height;
- }
- else if(cell.valign == "center")
- {
- voffset = (rows[r].maxCellDims.height - con._height) / 2;
- }
- else
- {
- voffset = 0;
- }
- if(c == 0)
- {
- x = this.x;
- lastColMax = cwid;
- }
- else
- {
- cmax = lastColMax;
- x += cmax + this.cellSpacing;
- }
- con._x = x + offset;
- con._y = y + voffset;
- if(this.borderSize > 0)
- {
- this.borderClip.lineStyle(this.borderSize,10066329,100);
- this.borderClip.drawRect(x,y,cwid,rows[r].maxCellDims.height);
- }
- lastColMax = cwid;
- c++;
- }
- r++;
- }
- this._recalcHeights();
- };
- TableClass.prototype._resizeTextfield = function(oIns, w, h)
- {
- var txt = oIns.content;
- if(txt._width > w)
- {
- txt.wordWrap = true;
- txt._width = w;
- txt._width = Math.round(txt._width);
- trace("text width: " + txt.textWidth);
- if(this.reduceTextFields)
- {
- var h = txt._height;
- var w = txt._width;
- var old_w = 0;
- var txtWidth = txt.textWidth;
- var i = w;
- while(h == txt._height)
- {
- if(i <= 0)
- {
- break;
- }
- if(txt.textWidth < txtWidth)
- {
- break;
- }
- txt._width--;
- i--;
- }
- txt._width = txt._width + 1;
- }
- }
- oIns._width = txt._width;
- };
- TableClass.prototype._recalcHeights = function()
- {
- var rows = this.rows;
- var rc = rows.length;
- var cc;
- var cols;
- var cell;
- this.height = 0;
- var r = 0;
- while(r < rc)
- {
- cols = rows[r].cells;
- cc = cols.length;
- var c = 0;
- while(c < cc)
- {
- cell = cols[c];
- rows[r]._checkMaxCellDims(cell);
- this.height += rows[r].maxCellDims.height;
- c++;
- }
- r++;
- }
- };
- TableClass.prototype._findLargestColumn = function()
- {
- var largestId;
- var largest;
- var cmaxs = this.colWidthMaxs;
- var i = 0;
- while(i < cmaxs.length)
- {
- trace("finding largest: " + cmaxs[i]);
- if(largest < cmaxs[i])
- {
- largest = cmaxs[i];
- largestId = i;
- }
- i++;
- }
- return largestId;
- };
- TableClass.prototype._recalcDimensions = function(newWidth)
- {
- var cw = this._getTableWidth();
- if(newWidth > cw)
- {
- return undefined;
- }
- trace("\n\n----");
- trace("TableClass.prototype._recalcDimensions:");
- trace("current width: " + cw + ", new width: " + newWidth);
- delete this.alteredColumns;
- this.alteredColumns = {};
- this._resizeTableR(cw,newWidth);
- var addback = newWidth - this._getTableWidth();
- var cmaxs = this.colWidthMaxs;
- var prc;
- var cmax = 0;
- var acc = 0;
- for(var nm in this.alteredColumns)
- {
- trace("ALTERED COLUMNS: " + nm);
- if(!isNaN(nm))
- {
- acc++;
- }
- }
- for(var colid in this.alteredColumns)
- {
- trace("Addback: " + colid + ", " + addback / acc);
- this.colWidthMaxs[parseInt(colid)] = this.colWidthMaxs[parseInt(colid)] + addback / acc;
- }
- if(addback / acc > 0)
- {
- }
- this.width = newWidth;
- };
- TableClass.prototype._resizeTableR = function(lastWidth, targetWidth)
- {
- if(lastWidth <= targetWidth)
- {
- return undefined;
- }
- var largest;
- var largestId = 0;
- var cmaxs = this.colWidthMaxs;
- var i = 0;
- while(i < cmaxs.length)
- {
- trace("finding largest: " + cmaxs[i]);
- if(largest < cmaxs[i])
- {
- largest = cmaxs[i];
- largestId = i;
- }
- i++;
- }
- var prc = largest / lastWidth;
- trace("prc: " + prc);
- var ncw = largest * prc;
- cmaxs[largestId] = ncw;
- this.alteredColumns[largestId] = largestId;
- trace("\n\nAFTER:");
- trace("new largest: " + ncw);
- trace("lastWidth: " + lastWidth);
- trace("largest: " + largest);
- trace("targetWidth: " + targetWidth);
- trace("nextWidth: " + (lastWidth - (largest - ncw)));
- if(prc == 1)
- {
- cmax[largestId] = targetWidth;
- return undefined;
- }
- this._resizeTableR(lastWidth - (largest - ncw),targetWidth);
- };
- TableClass.prototype._getTableWidth = function()
- {
- var width = 0;
- var lasti = this.colWidthMaxs.length - 1;
- var i = 0;
- while(i < this.colWidthMaxs.length)
- {
- width += this.colWidthMaxs[i];
- i++;
- }
- return width;
- };
- TableClass.prototype.init = function()
- {
- this.redraw();
- };
- TableRow = function()
- {
- this.cells = [];
- this.maxCellDims = {width:0,height:0};
- };
- TableRow.prototype.addCell = function(cell)
- {
- this.cells.push(cell);
- var cc = cell.getContent();
- var cw = cc == null ? cell.width : cc._width;
- var ch = cc == null ? cell.height : cc._height;
- var mw = this.maxCellDims.width;
- var mh = this.maxCellDims.height;
- this.maxCellDims.width = cw <= mw ? mw : cw;
- this.maxCellDims.height = ch <= mh ? mh : ch;
- };
- TableRow.prototype._checkMaxCellDims = function(cell)
- {
- var cc = cell.getContent();
- var cw = cc == null ? cell.width : cc._width;
- var ch = cc == null ? cell.height : cc._height;
- var mw = this.maxCellDims.width;
- var mh = this.maxCellDims.height;
- this.maxCellDims.width = cw <= mw ? mw : cw;
- this.maxCellDims.height = ch <= mh ? mh : ch;
- };
- TableCell = function(content)
- {
- this.content = content;
- };
- TableCell.prototype.setContent = function(content)
- {
- this.content = content;
- };
- TableCell.prototype.getContent = function()
- {
- return this.content;
- };
- TableCell.prototype.setWidth = function(width, isPercent)
- {
- this.widthIsPercent = isPercent != null ? true : false;
- this.width = width;
- };
- TableCell.prototype.setHeight = function(height, isPercent)
- {
- this.heightIsPercent = isPercent != null ? true : false;
- this.height = height;
- };
- TableCell.prototype.setHAlign = function(halign)
- {
- this.halign = halign;
- };
- TableCell.prototype.setVAlign = function(valign)
- {
- this.valign = valign;
- };
- Image = function(parent, name, depth, url)
- {
- this.$keepAspect = true;
- this.load(parent,name,depth,url);
- };
- Image.prototype.setKeepAspectRatio = function(keepAspect)
- {
- this.$keepAspect = keepAspect;
- };
- Image.prototype.load = function(parent, name, depth, url)
- {
- if(parent != null && name != null && depth != null && url != null)
- {
- if(!this.$mc)
- {
- }
- this.$parent = parent;
- this.$name = name;
- this.$depth = depth;
- this.$url = url;
- this.$mc = parent.createEmptyMovieClip(name,depth);
- this.$mc.drawRect(100,100,100,100);
- this.$mc._width = 100;
- this.$mc.onLoad = function()
- {
- this.onEnterFrame = function()
- {
- if(this._height > 0)
- {
- onLoad();
- delete this.onEnterFrame;
- }
- };
- };
- this.$mc.onLoad.parent = this;
- this.$mc.loadMovie(url);
- return this.$mc;
- }
- };
- Image.prototype.$_onLoad = function()
- {
- this.onEnterFrame = function()
- {
- if(this._height > 0)
- {
- this.onLoad.parent.onLoad.call(this.onLoad.parent,arguments);
- delete this.onEnterFrame;
- }
- };
- };
- Image.prototype.getClipInstance = function()
- {
- return this.$mc;
- };
- Image.prototype.setWidth = function(width)
- {
- if(this.$keepAspect)
- {
- if(this.$aspectRatio == null)
- {
- this.$setAspectRatio();
- }
- this.$mc._xscale = width / this.$mc._width * 100;
- this.$mc._yscale = this.$mc._xscale;
- }
- else
- {
- this.$mc._width = width;
- }
- };
- Image.prototype.setHeight = function(height)
- {
- if(this.$keepAspect)
- {
- this.$mc._yscale = height / this.$mc._height * 100;
- this.$mc._xscale = this.$mc._yscale;
- }
- else
- {
- this.$mc._height = height;
- }
- };
- Image.prototype.resize = function(width, height)
- {
- this.setWidth(width);
- this.setHeight(height);
- };
- Image.prototype.$setAspectRatio = function()
- {
- this.$aspectRatio = this.$mc._width <= this.$mc._height ? this.$mc._height / this.$mc._width : this.$mc._width / this.$mc._height;
- };
- TextFormat.prototype.cGetTextExtent = function(s, bEmbedFonts, bAccurate)
- {
- var __CGTE_mc = _root.createEmptyMovieClip("__PMSI_textExtBox__",4013145);
- __CGTE_mc._visible = false;
- __CGTE_mc.createTextField("content",1,0,0,0,0);
- var __CGTE_mc_txt = __CGTE_mc.content;
- __CGTE_mc_txt.autoSize = true;
- var __CGTE_marg_h = bAccurate != true ? 0 : __CGTE_mc_txt._height;
- var __CGTE_marg_v = bAccurate != true ? 0 : __CGTE_mc_txt._width;
- __CGTE_mc_txt.embedFonts = bEmbedFonts != null ? bEmbedFonts : true;
- __CGTE_mc_txt.type = "dynamic";
- __CGTE_mc_txt.selectable = false;
- __CGTE_mc_txt.text = s;
- __CGTE_mc_txt.setTextFormat(this);
- return {width:__CGTE_mc_txt._width - __CGTE_marg_h,height:__CGTE_mc_txt._height - __CGTE_marg_v};
- };
- TextField.prototype.findLines = function(ttf)
- {
- var mc2 = _root.createEmptyMovieClip("__getLinesBox__",4013146);
- mc2._visible = false;
- ttf = ttf != null ? ttf : this.getTextFormat();
- var lh = ttf.cGetTextExtent("373_<3_4").height;
- var lines = [];
- mc2.createTextField("__fio__",1000,0,0,0,0);
- var f = mc2.__fio__;
- var als = this.text.split(" ");
- f._width = this._width;
- f.embedFonts = this.embedFonts;
- f.border = this.border;
- f.type = "dynamic";
- f.autoSize = true;
- f.selectable = false;
- f.wordWrap = true;
- f.multiline = true;
- var line = "";
- var i = 0;
- while(i < als.length)
- {
- f.text += " " + als[i];
- f.setTextFormat(ttf);
- if(f._height > lh && line != "")
- {
- lines.push(line.trim());
- f.text = "";
- line = "";
- i--;
- }
- line = f.text;
- f.setTextFormat(ttf);
- i++;
- }
- lines.push(f.text.trim());
- f.removeTextField();
- this.__lines = lines;
- return lines;
- };
- TextField.prototype.getLineAt = function(i)
- {
- if(this.__lines == null)
- {
- this.findLines();
- }
- return this.__lines[i];
- };
- TextField.prototype.getLineCount = function()
- {
- if(this.__lines == null)
- {
- this.findLines();
- }
- return this.__lines.length;
- };
- TextField.prototype.convertToLines = function()
- {
- if(this.__lines == null)
- {
- this.findLines();
- }
- this.text = "";
- var i = 0;
- while(i < this.__lines.length - 1)
- {
- this.text += this.__lines[i] + "\n";
- i++;
- }
- this.text += this.__lines[this.__lines.length - 1];
- };
- TextField.prototype.getLines = function()
- {
- if(this.__lines == null)
- {
- this.findLines();
- }
- return this.__lines;
- };
- stop();
- _global.strace = function(s)
- {
- };
- if(_parent)
- {
- master = _parent;
- }
- else
- {
- master = this;
- }
- if(master.layoutInfo == null)
- {
- var layoutInfo = {};
- layoutInfo.titleTextColor = 3636920;
- layoutInfo.answerRollOverColor = 16695085;
- layoutInfo.answerRollOutColor = 3636920;
- layoutInfo.answerSelectColor = 2309272;
- layoutInfo.questionTextColor = 2309272;
- layoutInfo.instTextColor = 2309272;
- layoutInfo.doAnswerFill = false;
- layoutInfo.rightSideBuffer = 10;
- layoutInfo.box = {};
- layoutInfo.box.x = 260;
- layoutInfo.box.y = 98;
- layoutInfo.box.views = [];
- layoutInfo.box.widthWithBox = 300;
- layoutInfo.box.heightWithBox = 300;
- layoutInfo.box.widthWithoutBox = 300;
- layoutInfo.box.heightWithoutBox = 300;
- layoutinfo.MAX_WIDTH = 520;
- layoutInfo.MAX_HEIGHT = 380;
- layoutInfo.questionIndent = 30;
- layoutInfo.selectionRadius = 6;
- layoutInfo.drawSelectionCircle = true;
- layoutInfo.lineSpacing = 5;
- layoutInfo.selectionBorderThickness = 1;
- layoutInfo.instTextFormat = new TextFormat();
- layoutInfo.instTextFormat.font = "Formata_Normal";
- layoutInfo.instTextFormat.size = 12;
- layoutInfo.instTextFormat.color = layoutInfo.instTextColor;
- layoutInfo.qTextFormat = new TextFormat();
- layoutInfo.qTextFormat.font = "Formata_Normal";
- layoutInfo.qTextFormat.size = 12;
- layoutInfo.qTextFormat.color = layoutInfo.questionTextColor;
- layoutInfo.qTextFormat.align = "right";
- layoutInfo.answerTextFormat1 = new TextFormat();
- layoutInfo.answerTextFormat1.font = "Formata_Normal";
- layoutInfo.answerTextFormat1.size = 12;
- layoutInfo.answerTextFormat1.color = layoutInfo.answerRollOutColor;
- layoutInfo.answerTextFormat2 = new TextFormat();
- layoutInfo.answerTextFormat2.font = "Formata_Normal";
- layoutInfo.answerTextFormat2.size = 12;
- layoutInfo.answerTextFormat2.color = layoutInfo.answerRollOutColor;
- layoutInfo.titleTextFormat = new TextFormat();
- layoutInfo.titleTextFormat.font = "TriplexCondSerifBlack";
- layoutInfo.titleTextFormat.size = 24;
- layoutInfo.titleTextFormat.color = layoutInfo.titleTextColor;
- layoutInfo.matchingCircleColor = 16695085;
- layoutInfo.matchingCircleRadius = 4;
- layoutInfo.matchingCircleSpacer = 50;
- layoutInfo.matchingCircleLineThickness = 2;
- layoutInfo.matchingCircleVertOffset = 4;
- }
- else
- {
- layoutInfo = master.layoutInfo;
- }
- layoutInfo.qStaticText = new TextFormat();
- layoutInfo.qStaticText.font = "Formata_Normal";
- layoutInfo.qStaticText.size = 12;
- layoutInfo.qStaticText.color = layoutInfo.questionTextColor;
- layoutInfo.qFillText = new TextFormat();
- layoutInfo.qFillText.font = "Formata_Normal";
- layoutInfo.qFillText.size = 12;
- layoutInfo.qFillText.indent = 0;
- layoutInfo.qFillText.align = "center";
- layoutInfo.qFillText.color = layoutInfo.answerRollOutColor;
- layoutInfo.qNumberText = new TextFormat();
- layoutInfo.qNumberText.font = "Formata_Normal";
- layoutInfo.qNumberText.size = 12;
- layoutInfo.qNumberText.color = layoutInfo.questionTextColor;
- TAGS = {};
- TAGS.BLANK_OPEN = "[:blank:]";
- TAGS.BLANK_CLOSE = "[:/blank:]";
- testFile = "activities/data/C3.U6.S2.GR.C5.xml";
- var ai = new ActivityInfo();
- ai._parent = this;
- ai.onLoad = function(success)
- {
- var i = 0;
- while(i < this.questions.question.length)
- {
- i++;
- }
- this._parent.render();
- };
- if(_parent == null)
- {
- loadActivity(testFile);
- }
- BOX_WIDTH = 270;
- depth = 1000;
- if(_parent)
- {
- __fio__.removeTextField();
- }
- __fio__._visible = false;
- d;
-